
#ifndef ROPUFU_DISTRIBUTED_MATRIX_HPP_INCLUDED
#define ROPUFU_DISTRIBUTED_MATRIX_HPP_INCLUDED

#include <aftermath/algebra/matrix.hpp>

#include <cstdint>

namespace ropufu
{
    namespace distributed
    {
        template <typename t_data_type>
        struct matrix : public aftermath::algebra::matrix<t_data_type>
        {
        public:
            using aftermath::algebra::matrix<t_data_type>::matrix;

            std::size_t get_local_height() const
            {
                return this->get_height();
            }

            std::size_t get_local_width() const
            {
                return this->get_width();
            }

            std::size_t get_global_height() const
            {
                return this->get_height();
            }

            std::size_t get_global_width() const
            {
                return this->get_width();
            }

            void write(std::size_t row_index, std::size_t column_index, const t_data_type& value)
            {
                this->operator()(row_index, column_index) = value;
            }

            const t_data_type& read(std::size_t row_index, std::size_t column_index) const
            {
                return this->operator()(row_index, column_index);
            }
        };

        struct matrix_helper
        {
            template <typename t_data_type>
            static matrix<t_data_type> create_row_vector(const std::vector<t_data_type>& vect)
            {
                return matrix<t_data_type>(1UL, vect.size(), vect.data());
            }

            template <typename t_data_type>
            static matrix<t_data_type> create_column_vector(const std::vector<t_data_type>& vect)
            {
                return matrix<t_data_type>(vect.size(), 1UL, vect.data());
            }

            template <typename t_data_type>
            static matrix<t_data_type> create(const t_data_type& single_element)
            {
                return matrix<t_data_type>(1UL, 1UL, single_element);
            }
        };
    }
}

#endif // ROPUFU_DISTRIBUTED_MATRIX_HPP_INCLUDED
